const dynamicProxy = require('./environments/proxy.js')
export default {
  server: {
    port: 8088
  },
  head: {
    title: 'GimiShare',
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' },
      {
        hid: 'description',
        name: 'description',
        content: 'GimiShare主打技术分享，记录身边趣事与您共同分享。'
      },
      {
        hid: 'keywords',
        name: 'keywords',
        content: 'GimShare，技术分享，学习，指南'
      },
      { name: 'format-detection', content: 'telephone=no' },
      { name: 'referrer', content: 'no-referrer' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.svg' },
      {
        rel: 'stylesheet',
        href: '//at.alicdn.com/t/c/font_3367936_4nnen8te1bx.css'
      }
    ],
    script: [
      { src: '/md/highlightjs/highlight.min.js' }
    ]
  },

  css: [
    'remixicon/fonts/remixicon.css',
    'ant-design-vue/dist/antd.css',
    '~/style/antd.less',
    '~/style/gloab.less',
    '~/style/markdown.less',
    '~/style/theme.css',
    `~/style/media.less`
  ],

  styleResources: {
    less: []
  },

  router: {
    linkActiveClass: 'nuxt-link-active',
    linkExactActiveClass: 'nuxt-link-exact-active',
    middleware: ['auth']
  },

  plugins: [
    '~/plugins/antd-ui',
    '~/plugins/axios',
    {
      src: '~/plugins/mavon-editor',
      ssr: false
    },
    {
      src: '~/plugins/directives',
      ssr: false
    },
    '~/plugins/filters'
  ],

  components: {
    globals: {
      'HeadAvatar': '~/components/HeadAvatar.vue'
    }
  },

  buildModules: [
    '@nuxtjs/eslint-module',
    '@nuxtjs/stylelint-module',
    '@nuxtjs/style-resources'
  ],

  modules: [
    '@nuxtjs/axios',
    'cookie-universal-nuxt',
    '@nuxtjs/style-resources'
  ],

  axios: {
    prefix: '',
    proxy: true
  },

  proxy: dynamicProxy.proxy,

  build: {
    extractCSS: {
      alChunks: process.env.NODE_ENV === 'production'
    },
    vendor: ['external_libary'],
    optimization: {
      splitChunks: {
        cacheGroups: {
          styles: {
            name: 'styles',
            test: /\.(css|vue|less)$/,
            chunks: 'all',
            enforce: true
          }
        }
      }
    },
    extend (config, { isClient }) {
      if (isClient) {
        config.node = {
          fs: 'empty'
        }
      }
    }
  },

  loading: {
    color: '#46bf68'
  },

  dev: process.env.NODE_ENV === 'development'
}
